//package com.radiation.rms.filter;
//
//
//import com.google.gson.JsonObject;
//import org.springframework.core.io.buffer.DataBuffer;
//import org.springframework.http.server.reactive.ServerHttpResponse;
//import org.springframework.stereotype.Component;
//import org.springframework.web.servlet.HandlerInterceptor;
//import org.springframework.web.servlet.ModelAndView;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//import java.nio.charset.StandardCharsets;
//import java.util.Enumeration;
//import java.util.List;
//
//@Component
//public class UserInterceptor implements HandlerInterceptor {
//
//    //这个方法是在访问接口之前执行的，我们只需要在这里写验证登陆状态的业务逻辑，就可以在用户调用指定接口之前验证登陆状态了
//    @Override
//    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//        Enumeration<String> token = request.getHeaders("token");
//        if (null == token) {
//            request.setAttribute("login_error", "请先登录");
//            request.getRequestDispatcher("/").forward(request, response);
//            return false;
//        }else {
//            return true;
//        }
//    }
//    @Override
//    public void postHandle(
//            HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView)
//            throws Exception {
//    }
//
//    @Override
//    public void afterCompletion(
//            HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
//            throws Exception {
//
//    }
//}